/**
 * Copyright (C) 2009 Lazaro Brito
 *
 * This file is part of jIRC.
 * 
 * jIRC is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * jIRC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with jIRC.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package org.lazaro.jirc.proto;

/**
 * @author Lazaro Brito
 *
 */
public class CommandBuilder {
	private final String opcode;
	private StringBuilder command = new StringBuilder();

	public CommandBuilder(String opcode) {
		this.opcode = opcode;
		command.append(opcode);
	}

	public CommandBuilder append(Object arg) {
		append(arg, false);
		return this;
	}

	public CommandBuilder append(Object arg, boolean colon) {
		command.append(" ");
		if(colon) {
			command.append(":");
		}
		command.append(arg);
		return this;
	}

	public String getOpcode() {
		return opcode;
	}

	public String toString() {
		return command.toString();
	}
}